#!/bin/bash

SUDO_PASSWD="123"
SSH_PASSWD=${SUDO_PASSWD}
SSH_USER="rk"
SSH_SERVER="192.168.1.55"
SAMBA_SHARE_DIR="/home/samba/samba_share/tmpshare/"

SSH_SERVER2="192.168.1.88"
SAMBA_SHARE_DIR2="/datadisk/tmpshare/"

function sudo_cmd()
{
	if [[ $# -lt 1 ]]; then
		return
	fi

	local cmd=$@
	echo ${SUDO_PASSWD} | sudo -p "-" -kS bash -c "${cmd}"
}

function sudo_cmd_check_w()
{
	if [[ $# -lt 2 ]]; then
		return
	fi

	local file=$1
	shift
	local cmd=$@

	if [[ -w ${file} ]]; then
		bash -c "${cmd}"
	else
		sudo_cmd ${cmd}
	fi
}

function scp_from_samba()
{
	local samba_src_file=$1
	local dst_file=$2
	sshpass -p ${SSH_PASSWD} scp ${SSH_USER}@${SSH_SERVER}:${SAMBA_SHARE_DIR}/${src_file_samba} \
			${dst_file}
}
